﻿@{
    ViewBag.Title = "标的详情";

    var loaninfo = ViewBag.LoanInfo as LoanInfo;
    var projectProcess = ViewBag.ProjectProcess as ProjectProcess;
    var riskControl = ViewBag.RiskControl as RiskControl;
    
}   
@using QDT.Core
@using QDT.Core.Projects
@using QDT.MVC
@using QDT.Services.DTO.Project
@model QDT.Core.Projects.Project

@section Head{
    <style>
        .p-box{border-bottom: 1px solid #e5e5e5;padding-bottom: 10px; }
        .p-box-top{margin-top: 10px; }
        .p-box-bottom{margin-bottom: 10px; }
        .p-table{padding-left: 26px;padding-right: 26px;}
        .p-table1{padding-right: 26px;}

        .p-nav { list-style: none; }
        .p-nav-tabs {margin-top: 20px;}

        .p-nav-tab{ float: left;font-size: 16px;padding: 16px 26px;border-bottom: 1px solid #e5e5e5;}
        .p-nav-tab.active{margin-top: -1px;border-bottom: none;border-left: 1px solid #e5e5e5;border-right: 1px solid #e5e5e5;border-top: 3px solid #e8362c; }
        .p-nav-tab a{color:#e72b21;}
        .p-nav-tab a:hover{color:#ff8383;}
        .p-nav-tab.active a{color:#555555;}
        
        .p-img1{width: 160px;height:120px;}
        .ui-box-side1{width:340px;float:right;display:inline;}
        .p-invest-box1 {margin-left: 16px;}
        .p-invest-box2 {background: #f9f9f9;display: block;width: 80%;padding-bottom: 20px;-webkit-border-radius: 6px;}

        .p-process1 {float: left;width: 375px;text-align: center}
        .p-process2 {float: left;width: 375px;}
        .p-process3 {margin-left: 75px;padding: 5px 0 20px 75px;border-left: solid 2px #e74c3c;}
        .p-process4 {padding: 5px 0 20px 0;}
        
        .p-active{font-size: 16px;color: #e74c3c;}
        
        .p-process-point{position: relative;left: 65px; display: block;}
        .p-process-point1{top: 24px;}
        .p-process-point2{top: 72px;}
        .p-process-point3{top: 118px;}
        .p-process-point4{top: 166px;}
        .p-process-point5{top: 208px;}
        .p-process-point6{top: 256px;}
        .p-process-point7{top: 300px;}
        .p-process-point8{top: 348px;}
        
        button.bid-submit {margin: 10px 0; height:40px;line-height:40px;font-size:16px;color: #fff;width: 256px;background: #ffa024;-webkit-border-radius: 2px;border: 1px solid #ffa024;}
        input.bid-money{margin: 10px 0; height: 34px;width: 256px;-webkit-border-radius: 6px;border: 1px solid #c0c0c0;}
    </style>
}

<div style="background: #f8f8f8; border-bottom: 1px solid #e5e5e5; display: block; height: 23px;"></div>
<div style="border-bottom: 2px solid #e5e5e5;">
    <div class="ui-inner" style="height: 43px; line-height: 43px;">
        <span style="font-size: 16px;"><a href="@Url.Action("ProjectList","Home")">项目列表 > </a></span><span style="color: #E74C3C; font-size: 16px;">标详情</span>
    </div>
</div>
<div style="padding: 20px 0;">
    <div class="ui-inner">
        <div class="fn-clear">
            <div class="ui-box-mian">
                
            @Html.Action("PojectInfo", new {id = Model.ID})
                
                <div class="p-box-top font-size14" style="height: 80px;width: 100%;">
                    <ul class="p-nav p-nav-tabs" style="position: relative">
                        <li class="p-nav-tab active" data-nav="ProjectInfo"><a href="javascript:;" >项目信息</a></li>
                        <li class="p-nav-tab" data-nav="InverstInfo"><a href="javascript:;">投资记录</a></li>
                        <li class="p-nav-tab" data-nav="RepayPlan"><a href="javascript:;">还款计划</a></li>
                        <li class="p-nav-tab" data-nav="ImageInfo"><a href="javascript:;" >相关资质</a></li>
                        <li class="p-nav-tab" data-nav="ProjectProcess"><a href="javascript:;">项目历程</a></li>
                    </ul>
                </div>
                
                <div id="ProjectInfo" class="nav">
                    <div class="p-box p-table font-size14">
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td class="td td1">
                                        @(loaninfo != null ? loaninfo.Key01 : "")
                                    </td>
                                    <td class="td td2">
                                        @(loaninfo != null ? loaninfo.Value01 : "")
                                    </td>
                                    <td class="td td3">
                                        @(loaninfo != null ? loaninfo.Key04 : "")
                                    </td>
                                    <td class="td td4">
                                        @(loaninfo != null ? loaninfo.Value04 : "")
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td td1">
                                        @(loaninfo != null ? loaninfo.Key02 : "")
                                    </td>
                                    <td class="td td2">
                                        @(loaninfo != null ? loaninfo.Value02 : "")
                                    </td>
                                    <td class="td td3">
                                        固定还款日
                                    </td>
                                    <td class="td td4">
                                        每月<span>@Model.SettleDay</span>日
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td td1">
                                        @(loaninfo != null ? loaninfo.Key03 : "")
                                    </td>
                                    <td class="td td2">
                                        @(loaninfo != null ? loaninfo.Value03 : "")
                                    </td>
                                    <td class="td td3">
                                        已融资额度
                                    </td>
                                    <td class="td td4">
                                        @Html.F().GetLoanSuccessMoney(Model.ParentId)万
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td td1">
                                        @(loaninfo != null ? loaninfo.Key05 : "")
                                    </td>
                                    <td class="td td2">
                                        @(loaninfo != null ? loaninfo.Value05 : "")
                                    </td>
                                    <td class="td td3">
                                        @(loaninfo != null ? loaninfo.Key06 : "")
                                    </td>
                                    <td class="td td4">
                                        @(loaninfo != null ? loaninfo.Value06 : "")
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td td1">
                                        @(loaninfo != null ? loaninfo.Key07 : "")
                                    </td>
                                    <td class="td td2">
                                        @(loaninfo != null ? loaninfo.Value07 : "")
                                    </td>
                                    <td class="td td3">
                                        @(loaninfo != null ? loaninfo.Key08 : "")
                                    </td>
                                    <td class="td td4">
                                        @(loaninfo != null ? loaninfo.Value08 : "")
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="p-table font-size14">
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td class="tdb td1">
                                        @(loaninfo != null ? loaninfo.Key09 : "")
                                    </td>
                                    <td class="tdb td5">
                                        @(loaninfo != null ? loaninfo.Value09 : "")
                                    </td>
                                </tr>
                                <tr class="tr1">
                                    <td class="tdb td1">
                                        @(loaninfo != null ? loaninfo.Key10 : "")
                                    </td>
                                    <td class="tdb td5">
                                        @(loaninfo != null ? loaninfo.Value10 : "")
                                    </td>
                                </tr>
                                <tr class="tr1">
                                    <td class="tdb td1">
                                        @(loaninfo != null ? loaninfo.Key11 : "")
                                    </td>
                                    <td class="tdb td5">
                                        @(loaninfo != null ? loaninfo.Value11 : "")
                                    </td>
                                </tr>
                                <tr class="tr1">
                                    <td class="tdb td1">
                                        @(loaninfo != null ? loaninfo.Key12 : "")
                                    </td>
                                    <td class="tdb td5">
                                        @(loaninfo != null ? loaninfo.Value12 : "")
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>

                <div id="project_bid_list">
                    @Html.Action("BidList", new { projectid = Model.ID })
                </div>
                
                   
                @if (Model.Status == ProjectStatus.Repaying || Model.Status == ProjectStatus.Repaid)
                {
                    if (!Model.Rate.Equals(0.4))
                    {
                        @Html.Action("RepayList", new { projectid = Model.ID })
                    }
                }
                else
                {
                    <div id="RepayPlan" class="nav hide">
                        <div class="font-size14">
                            <table class="table">
                                <thead>
                                    <tr style="height: 40px;line-height: 40px;border-bottom: solid 1px #e5e5e5;">
                                        <th class="td6" style="width: 30%">预期还款时间</th>
                                        <th style="width: 25%">类型</th>
                                        <th style="width: 30%">还款金额(元)</th>
                                        <th style="width: 15%"></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                }
                
                  @Html.Action("OtherFile", new { projectId = Model.Parent.ID })

                <div id="ProjectProcess" class="nav hide">
                    <div class="font-size14 p-box">
                        <div class="p-process1">
                            项目历程
                        </div>
                        <div>
                            项目时间
                        </div>
                    </div>
                    <img src="/Content/Default/Images/About/time-point.png" class="p-process-point" />
                    <div id="process-1" class="font-size14">
                        <div class="p-process2">
                            <div class="p-process3">
                                @(projectProcess != null ? projectProcess.Key01 : "")
                            </div>
                        </div>
                        <div class="p-process4">
                                @(projectProcess != null ? projectProcess.Value01 : "")
                        </div>
                    </div>
                    <div id="process-2" class="font-size14">
                        <div class="p-process2">
                            <div class="p-process3">
                                @(projectProcess != null ? projectProcess.Key02 : "")
                            </div>
                        </div>
                        <div class="p-process4">
                                @(projectProcess != null ? projectProcess.Value02 : "")
                        </div>
                    </div>
                    <div id="process-3" class="font-size14">
                        <div class="p-process2">
                            <div class="p-process3">
                                @(projectProcess != null ? projectProcess.Key03 : "")
                            </div>
                        </div>
                        <div class="p-process4">
                                @(projectProcess != null ? projectProcess.Value03 : "")
                        </div>
                    </div>
                    <div id="process-4" class="font-size14">
                        <div class="p-process2">
                            <div class="p-process3">
                                @(projectProcess != null ? projectProcess.Key04 : "")
                            </div>
                        </div>
                        <div class="p-process4">
                                @(projectProcess != null ? projectProcess.Value04 : "")
                        </div>
                    </div>
                    <div id="process-5" class="font-size14">
                        <div class="p-process2">
                            <div class="p-process3">
                                @(projectProcess != null ? projectProcess.Key05 : "")
                            </div>
                        </div>
                        <div class="p-process4">
                                @(projectProcess != null ? projectProcess.Value05 : "")
                        </div>
                    </div>
                    <div id="process-6" class="font-size14">
                        <div class="p-process2">
                            <div class="p-process3">
                                @(projectProcess != null ? projectProcess.Key06 : "")
                            </div>
                        </div>
                        <div class="p-process4">
                                @(projectProcess != null ? projectProcess.Value06 : "")
                        </div>
                    </div>
                    <div id="process-7" class="font-size14">
                        <div class="p-process2">
                            <div class="p-process3">
                                @(projectProcess != null ? projectProcess.Key07 : "")
                            </div>
                        </div>
                        <div class="p-process4">
                            @(projectProcess != null ? projectProcess.Value07 : "")
                        </div>
                    </div>
                    <div id="process-8" class="font-size14 ">
                        <div class="p-process2">
                            <div class="p-process3">
                                @(projectProcess != null ? projectProcess.Key08 : "")
                            </div>
                        </div>
                        <div class="p-process4">
                             @(projectProcess != null ? projectProcess.Value08 : "")
                        </div>
                    </div>
                </div>

                <br/><br/><br/>
            </div>

            <div class="ui-box-side1">
                
                @if (QDTContext.Current.IsAuthenticated)
                {

                    if (Model.Status == ProjectStatus.Progress)
                    {

                        var userAccount = Html.F().GetUserAccount(QDTContext.Current.User.UserAccountID);

                        <div id="bid_wait" class="@(Model.StartTime.Value < DateTime.Now ? "hide" : "")">
                            <div style="font-size: 16px; margin-bottom: 22px;">待售中</div>
                            <div class="p-invest-box1">
                                <div class="p-invest-box2 font-size16">
                                    <div style="text-align: center; padding-top: 26px;">可投金额：<span style="color: #f39c12; font-size: 16px;">@Model.NeedMoney.ToMoney()</span>元</div>
                                    <div style="text-align: center; color: #c0c0c0">@Model.StartTime.Value.ToString("MM-dd HH:mm") 开始售出</div>
                                </div>
                                <div class="ui-btn-big" style="background: #ccc; width: 80%; height: 40px; line-height: 40px; margin-top: 25px; font-size: 16px; -webkit-border-radius: 6px;">
                                    即将开始
                                </div>
                            </div>
                        </div>

                        <div id="bid_form" class="@(Model.StartTime.Value > DateTime.Now ? "hide" : "")">
                            <div style="font-size: 16px; margin-bottom: 22px;">立即投资</div>
                            <div class="p-invest-box1">
                                <div class="p-invest-box2 font-size16">
                                    <div style="text-align: center; padding-top: 26px;">可投金额：<span style="color: #f39c12; font-size: 16px;">@Model.NeedMoney.ToMoney()</span>元</div>
                                    <div style="text-align: center; color: #ccc">已发时间 @((DateTime.Now - Model.StartTime.Value).Hours) 小时 @((DateTime.Now - Model.StartTime.Value).Minutes) 分</div>
                                </div>
                            
                                <form action="@Url.Action("Bid")" method="POST">
                                    <p>
                                        <input type="hidden" name="ID" value="@Model.ID"/>
                                        <input type="hidden" name="safePassword" value=""/>
                                        <input id="bid-money" name="money" class="bid-money" type="text"/>
                                    </p>
                                    <p>
                                        <span style="padding-left: 15px; font-size: 14px;">可用余额：@userAccount.Money.ToMoney() 元 [<a href="@Url.Action("MoneyIncharge", "User")">充值</a>]</span>
                                    </p>
                                    <p>
                                        <button id="bid-submit" type="submit" class="bid-submit" >确认投资</button>
                                    </p>
                                </form>
                            </div>
                        </div>

                    }
                    else if (Model.Status == ProjectStatus.Full)
                    {
                        <div style="font-size: 16px; margin-bottom: 22px;">满标中</div>
                        <div class="p-invest-box1">
                            <div class="p-invest-box2 font-size16">
                                <div style="text-align: center; padding-top: 26px;">可投金额：<span style="color: #f39c12; font-size: 16px;">0.00</span>元</div>
                                <div style="text-align: center; color: #ccc">已售完</div>
                            </div>
                            <div class="ui-btn-big" style="width: 80%; height: 40px; margin-top: 25px; font-size: 16px; -webkit-border-radius: 6px;">
                                查看其他项目
                            </div>
                        </div>
                    }
                    else if (Model.Status == ProjectStatus.Repaying)
                    {
                        <div style="font-size: 16px; margin-bottom: 22px;">正在还款中</div>
                        <div class="p-invest-box1">
                            <div class="p-invest-box2 font-size16">
                                <div style="text-align: center; padding-top: 26px;">可投金额：<span style="color: #f39c12; font-size: 16px;">0.00</span>元</div>
                                <div style="text-align: center; color: #ccc">已售完</div>
                            </div>
                            <div class="ui-btn-big" style="width: 80%; height: 40px; margin-top: 25px; font-size: 16px; -webkit-border-radius: 6px;">
                                查看其他项目
                            </div>
                        </div>
                    }
                }
                else
                {
                        <div>
                            <div style="font-size: 16px; margin-bottom: 22px;"><a href="@Url.Action("LogIn", "Account")">请登录</a></div>
                            <div class="p-invest-box1">
                                <div class="p-invest-box2 font-size16">
                                    <div style="text-align: center; padding-top: 26px;">可投金额：<span style="color: #f39c12; font-size: 16px;">@Model.NeedMoney.ToMoney()</span>元</div>
                                    <div style="text-align: center; color: #c0c0c0">@Model.StartTime.Value.ToString("MM-dd HH:mm") 开始售出</div>
                                </div>
                                <a href="@Url.Action("LogIn", "Account")">
                                    <div class="ui-btn-big" style="background: #f39c12; width: 80%; height: 40px; line-height: 40px; margin-top: 25px; font-size: 16px; -webkit-border-radius: 6px;">
                                        <span style="color: #fff">立即登陆</span>
                                    </div>
                                </a>
                            </div>
                        </div>
                }
                
                <div style="padding: 20px 0 0 66px;"><i class="icon iconfont" style="color: #ffa500">&#xf00b7</i> 众禧贷提醒您：投资有风险</div>
                
                <div style="height: 40px;line-height: 40px;font-size: 16px;margin-bottom: 22px;padding-top:20px;width: 100%;border-bottom: solid 2px #e5e5e5;">风险控制</div>
                
                <div class="font-size14 p-table1">
                    <table class="table">
                        <tbody>
                            <tr>
                                <td class="tda td7">
                                    @(riskControl != null ? riskControl.Key01 : "")
                                </td>
                                <td class="tda">
                                    @(riskControl != null ? riskControl.Value01 : "")
                                </td>
                            </tr>
                            <tr>
                                <td class="tda td7">
                                    @(riskControl != null ? riskControl.Key02 : "")
                                </td>
                                <td class="tda">
                                    @(riskControl != null ? riskControl.Value02 : "")
                                </td>
                            </tr>
                            <tr class="p-box">
                                <td class="tda td7">
                                    @(riskControl != null ? riskControl.Key03 : "")
                                </td>
                                <td class="tda td8">
                                    @(riskControl != null ? riskControl.Value03 : "")
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="font-size14 p-table1">
                    <table class="table">
                        <tbody>
                            <tr>
                                <td class="td td7">
                                    @(riskControl != null ? riskControl.Key04 : "")
                                </td>
                                <td class="td td8">
                                    @(riskControl != null ? riskControl.Value04 : "")
                                </td>
                            </tr>
                            <tr class="tr3">
                                <td class="td td7">
                                    @(riskControl != null ? riskControl.Key05 : "")
                                </td>
                                <td class="td">
                                    @(riskControl != null ? riskControl.Value05 : "")
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>

            </div>

        </div>
    </div>
</div>

<script type="text/javascript">

    $(".p-nav-tab").click(function() {
        $(".p-nav-tab").removeClass("active");
        $(this).addClass("active");
        var nav = $(this).attr('data-nav');
        $(".nav").addClass("hide");
        $("#" + nav).removeClass("hide");
    });

    $("document").ready(function() {
        var process = 6;
        @if (Model.Status == ProjectStatus.Full)
        {
            <text>process = 7;</text>
        }else if (Model.Status == ProjectStatus.Repaying || Model.Status == ProjectStatus.Repaid)
        {
            <text>process = 8;</text>
        }
        $("#process-" + process).addClass("p-active");
        $(".p-process-point").addClass("p-process-point" + process);
    });

    $('#more_bid_list').click(function() {
        $("#project_bid_list").load("/Project/AllBidList?ProjectId=" + @Model.ID);
    });

    $("#bid-submit").click(function() {
        var m = $("#bid-money").val();
        if (m == null || m==0) {
            alert("请输入正确的投资金额");
            return false;
        }
    });

    @if (Model.StartTime.Value > DateTime.Now)
    {
        <text>
            $().ready(function () {
                var year = @Model.StartTime.Value.Year;
                var month = @Model.StartTime.Value.AddMonths(-1).Month;
                var day = @Model.StartTime.Value.Day;
                var hour = @Model.StartTime.Value.Hour;
                var minute = @Model.StartTime.Value.Minute;
                var start = new Date(year,month,day,hour,minute,0);
                setInterval(function () {
                    var now = new Date();
                    if (start < now) {
                        $('#bid_form').removeClass('hide');
                        $('#bid_wait').addClass('hide');
                    }
                }, 1000);
            });
        </text>
    }

</script>